package com.aaa.ssm.service.impl;

import com.aaa.ssm.dao.HospitalDao;
import com.aaa.ssm.entity.Department;

import com.aaa.ssm.entity.Hospital;
import com.aaa.ssm.service.HospitalService;
import com.aaa.ssm.util.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class HospitalServiceImpl implements HospitalService {
    @Resource
    private HospitalDao hospitalDao;

    /**
     * 通过医院编号查科室
     * @param hospId
     * @return
     */

    @Override
    public List<Department> queryByHospital(Integer hospId) {
        return hospitalDao.queryByHospital(hospId);
    }
    /**
     * 通过省编号查医院
     * @param hospProvince
     * @return
     */
    @Override
    public List<Hospital> queryAll(Integer hospProvince) {
        return hospitalDao.queryAll(hospProvince);
    }
    /**
     * 通过市区编号查医院
     * @param hospCity
     * @return
     */
    @Override
    public List<Hospital> queryByCity(Integer hospCity) {
        return hospitalDao.queryByCity(hospCity);
    }
    /**
     * 查询所有
     * @param hospital
     * @return
     */
    @Override
    public List<Hospital> queryByParam(Hospital hospital) {
        return hospitalDao.queryByParam(hospital);
    }
    /**
     * 通过Id查询
     * @param hospId
     * @return
     */
    @Override
    public Hospital queryById(Integer hospId) {
        return hospitalDao.queryById(hospId);
    }
    /**
     * 添加
     * @param hospital
     * @return
     */
    @Override
    public int add(Hospital hospital) {
        return hospitalDao.add(hospital);
    }
    /**
     * 更新
     * @param hospital
     * @return
     */
    @Override
    public int update(Hospital hospital) {
        return hospitalDao.update(hospital);
    }
    /**
     * 删除
     * @param hospId
     * @return
     */
    @Override
    public int delete(Integer hospId) {
        return hospitalDao.delete(hospId);
    }
    /**
     * 分页查询
     * @param page
     * @return
     */
    @Override
    public PageInfo queryByPage(Page<Hospital> page) {
        PageHelper.startPage(page.getPageNo(),page.getPageSize());
        return new PageInfo<>(hospitalDao.queryByParam(page.getData()));
    }
}
